package com.geline.word.controller;

import cn.hutool.core.io.FileUtil;
import com.geline.word.util.WordContent;
import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * 上传word文件并转为html localhost:8080/demoWord/upload/{id}
 * 下载word文件从html转为  localhost:8080/demoWord/export/{id}
 * 查询预览html  GET: localhost:8080/demoWord/getPreviewUrl/{id}
 * 删除word相关文件  delete: localhost:8080/demoWord/delete/{id}
 * @author: mengxin
 * @date: 2022/10/18 17:30
 */
//@RestController("/demoWord")
@Slf4j
public class DemoWordController extends AbstractWordController {

    @Override
    protected WordContent handleUploadFile(String id, File htmlFile) {
        WordContent wordContent = new WordContent();
        String text = FileUtil.readUtf8String(htmlFile);
        wordContent.setContent(text);
        wordContent.setFileName("test.docx");
        htmlFile.delete();
        return wordContent;
    }

    @Override
    protected WordContent getWordContent(String id) {
        return null;
    }

    @Override
    protected boolean deleteById(String id) {
        return false;
    }
}
